package com.zy.factory;

import com.zy.strategy.LoginStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 登录策略工厂类
 */
@Component
public class LoginStrategyFactory {

    //在上下文中获取到所有的具体登录策略，写入Map集合
    @Autowired
    private Map<String, LoginStrategy> loginStrategyMap = new HashMap<>();

    /**
     * 根据loginType返回登录策略实例
     * @param LoginType
     * @return
     */
    public LoginStrategy getInstance(String LoginType) {
        //根据指定的登录类型LoginType，在Map集合中返回到具体登录策略实例
        return loginStrategyMap.get(LoginType);
    }
}
